﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WarOfDev.EF;
using WarOfDev.Core.Common;


namespace WarOfDev.Services.Mail
{
    public class MailService
    {
        public const string NewPuzzleMailTemplateName="NewPuzzle";
        public const string NewCateMailTemplateName = "NewCate";

        public static void SendNewPostAddedMail(WarDevEntities db,Post post)
        {
            var queue = new MailQueue {
                CreatedBy = post.CreatedBy,
                CreatedOn=DateTime.Now,
                ModifiedBy = post.CreatedBy,
                ModifiedOn=DateTime.Now,
                Id=Guid.NewGuid().ToString(),
                ReferTo=post.Id,
                Status=(int)EnumMailQueueStatus.New,
                MailType = post.PostType == (int)EnumPostType.Cate ? (int)EnumMailQueueType.NewCate : (int)EnumMailQueueType.NewPuzzle,
                TemplateName= post.PostType==(int)EnumPostType.Cate ? NewCateMailTemplateName: NewPuzzleMailTemplateName
            };

            db.MailQueues.AddObject(queue);
        }
    }
}
